package com.ymatou.iapi.productquery.testcase;

import com.google.common.reflect.TypeToken;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mongodb.BasicDBObject;
import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.productmanager.parameter.SaleCommissionDto;
import com.ymatou.iapi.productmanager.parameter.UpdateCatalogCommisionsBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.parameter.product.CatalogSaveModel;
import com.ymatou.iapi.productmanager.service.UpdateCatalogCommisionsCall;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.productquery.parameter.ActivityCatalogInfo;
import com.ymatou.iapi.productquery.parameter.ActivityProducts;
import com.ymatou.iapi.productquery.parameter.GetProductListByProductIdListBean;
import com.ymatou.iapi.productquery.parameter.ProductInListDto;
import com.ymatou.iapi.productquery.parameter.ProductList.ProductInListBean;
import com.ymatou.iapi.productquery.service.GetProductListByProductIdListCall;
import com.ymatou.iapi.productquery.service.GetProductListByTradeIsolationCall;
import com.ymatou.iapi.sellerproduct.service.BatchDeleteProductsCall;
import com.ymatou.iapi.sellerproduct.service.ChangeNewProductInfoCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.business.service.productdata.bean.ProductBean;
import com.ymttest.business.service.productdata.impl.ProductFactory;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.mongo.YmtMongoDriverFactroy;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductsWapperV2;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.*;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Ts_GetProductListByProductIdList {
	private static GetProductListByProductIdListCall getProductListByProductIdListCall = new GetProductListByProductIdListCall();
	private static GetProductListByTradeIsolationCall getProductListByTradeIsolationCall = new GetProductListByTradeIsolationCall();
	private static GetProductListByProductIdListBean GetProductListByProductIdListBean;
	private static Integer sellerId = Integer.valueOf(EnvSetup.getData("productpriceSellerId"));
	private static String sellerName = EnvSetup.getData("productpriceSellerName");

	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("非交易隔离查询接口,获取商品简单信息");
		try {
			GodfreightmgrService.deleteBySellerId(rootUserId);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		GetProductListByProductIdListBean = new GetProductListByProductIdListBean();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getProductListByProductIdListCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_GetProductListByProductIdList_001() {
		Logger.start(true, "普通单规格商品，普通单规格直播商品 查询");
		try {
			// 发布商品
			JSONObject addProductBean = JsonBeanHelper
					.getJsonBean("com.ymatou.iapi.sellerproduct/AddNewSellerProduct/AddNewProductTpl_Tc2.json");
			JsonBeanHelper.updateJsonBean(addProductBean, MapUtil.hashMap("UserID", sellerId, "LoginID", sellerName));
			String productId = SellerProductCallService.addNewProduct(addProductBean).getJSONObject("Data")
					.getString("ProductID");

			List<String> prodList = Arrays.asList(productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

			// ================================================================================
			// 加入直播
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId))
					.getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, liveId, false);

			// check GetProductListByTradeIsolationt
			checkByProductList(prodList, 0, liveId, true);

			// ================================================================================
			// 结束直播
			LiveCallService.closeLive(liveId, Integer.valueOf(sellerId));

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

			// ================================================================================
			// 加入未开始直播
			liveId = LiveCallService.createLiveBeginInFuture(sellerName, Integer.valueOf(sellerId))
					.getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_GetProductListByProductIdList_002() {
		Logger.start(true, "普通多规格商品,普通多规格直播商品 查询");
		try {
			String productId = ProductQueryCallService.getNewProduct(sellerId, sellerName);
			List<String> prodList = Arrays.asList(productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

			// ================================================================================
			// 加入直播
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId))
					.getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, liveId, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, liveId, true);

			// ================================================================================
			// 暂停销售
			SellerProductCallService.suspendSaleProductInLive(sellerId, liveId, productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_003() {
		Logger.start(true, "普通活动商品查询");
		int activityId = 0;
		try {
			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId)
					.getProductId();

			List<String> prodList = Arrays.asList(productId);

			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			// check GetProductListByProductIdList
			checkByProductList(prodList, inaid, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, inaid, 0, true);

			// 结束活动
			// activityProductsWapper.update(inaid,
			// MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1)));
			AdminCallService.closeProductInActivity(String.valueOf(inaid));

			// ================================================================================
			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		} finally {
			if (activityId > 0) {
				ActivityPoolService.removeActivityIdFromPool(activityId);
			}
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_004() {
		Logger.start(true, "交易隔离活动商品查询");
		int activityId = 0;
		try {
			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation(sellerId)
					.getProductId();
			List<String> prodList = Arrays.asList(productId);
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, inaid, 0, true);

			// 结束活动
			// activityProductsWapper.update(inaid,
			// MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1)));
			AdminCallService.closeProductInActivity(String.valueOf(inaid));

			// ================================================================================
			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		} finally {
			if (activityId > 0) {
				ActivityPoolService.removeActivityIdFromPool(activityId);
			}
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_GetProductListByProductIdList_005() {
		Logger.start(true, "活动直播商品查询");
		try {
			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId)
					.getProductId();
			List<String> prodList = Arrays.asList(productId);
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());

			// ================================================================================
			// 加入直播
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId))
					.getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, inaid, liveId, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, inaid, liveId, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_006() {
		Logger.start(true, "普通多规格商品，增加规格");
		try {
			// 发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			List<String> prodList = Arrays.asList(productId);

			// check GetProductDetailListByProductIdListCall
			checkByProductList(prodList, 0, 0, false);

			// check GetProductDetailListByTradeIsolationCall
			checkByProductList(prodList, 0, 0, true);

			String fileName = "changenewproductinfocalltpl_003.json";
			new ChangeNewProductInfoCall().callAndGetReturnData(fileName, MapUtil.hashMap("LoginID", sellerName,
					"UserID", sellerId, "Product->sProductId", productId, "ProductID", productId));

			YMTDateUtil.waitTime(5);

			// check GetProductDetailListByProductIdListCall
			checkByProductList(prodList, 0, 0, false);

			// check GetProductDetailListByTradeIsolationCall
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_007() {
		Logger.start(true, "查询商品删除");
		try {
			JSONObject addProductBean = JsonBeanHelper
					.getJsonBean("com.ymatou.iapi.sellerproduct/AddNewSellerProduct/AddNewProductTpl_Tc2.json");
			JsonBeanHelper.updateJsonBean(addProductBean, MapUtil.hashMap("UserID", sellerId, "LoginID", sellerName));
			String productId = SellerProductCallService.addNewProduct(addProductBean).getJSONObject("Data")
					.getString("ProductID");

			// 删除商品
			new BatchDeleteProductsCall().callAndGetReturnData(
					MapUtil.hashMap("ProductIds", new JSONArray(Arrays.asList(productId)), "UserID", sellerId));

			YMTDateUtil.waitTime(5);
			JSONObject ret1 = getProductListByTradeIsolationCall.search(Arrays.asList(productId));
			Logger.verifyEquals(true, ret1.getJSONObject("Data").isNull("ProductList"), "删除商品不应查出");

			JSONObject ret2 = getProductListByProductIdListCall.search(Arrays.asList(productId));
			Logger.verifyEquals(true, ret2.getJSONObject("Data").isNull("ProductList"), "删除商品不应查出");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_008() {
		Logger.start(true, "普通活动商品查询,库存为0");
		int activityId = 0;
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId);
			String productId = productAllPriceBean.getProductId();

			List<String> prodList = Arrays.asList(productId);

			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			// check GetProductListByProductIdList
			checkByProductList(prodList, inaid, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, inaid, 0, true);

			// 活动库存为0 活动不显示 但IsCurActivitySellOut=true
			ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
			ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);

			// ================================================================================
			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		} finally {
			if (activityId > 0) {
				ActivityPoolService.removeActivityIdFromPool(activityId);
			}
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_009() {
		Logger.start(true, "交易隔离活动商品查询,库存为0");
		int activityId = 0;
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndIsolation(sellerId);
			String productId = productAllPriceBean.getProductId();

			List<String> prodList = Arrays.asList(productId);

			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, inaid, 0, true);

			// 活动库存为0 活动不显示 但IsCurActivitySellOut=true
			ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
			ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);

			// check GetProductListByProductIdList
			checkByProductList(prodList, 0, 0, false);

			// check GetProductListByTradeIsolation
			checkByProductList(prodList, 0, 0, true);

		} catch (Exception e) {
			Logger.fail(e);
		} finally {
			if (activityId > 0) {
				ActivityPoolService.removeActivityIdFromPool(activityId);
			}
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_010() {
		Logger.start(true, "下一场普通活动商品查询");

		try {

			// ProductBean productBean =
			// ProductFactory.getFutureActivityProduct(sellerId, sellerName,
			// null);
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Date beginTime1 = YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getBeforeOrNextSecond(3600));
			Date endTime1 = YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getBeforeOrNextSecond(7600));
			int aid = ProductPriceCallService.ApplyHighActivity("10", productId, beginTime1, endTime1).getActivityId();

			List<String> prodList = Arrays.asList(productId);

			if (YmtMongoDriverFactroy.IsNewJavaMongoOpen) {
				new ActivityProductsWapper().update(productId, MapUtil.hashMap("isolation", false));
			}

			// check GetProductListByProductIdList
			checkByProductList(prodList, 300, 0, 0, false, aid);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_011() {
		Logger.start(true, "下一场交易活动商品查询");

		try {

			ProductBean productBean = ProductFactory.getFutureActivityProduct(sellerId, sellerName, null);
			String productId = productBean.getProductId();
			// int aid =
			// productBean.getProductActivitysBean().getFutureActivitys().get(0);

			List<String> prodList = Arrays.asList(productId);

			if (YmtMongoDriverFactroy.IsNewJavaMongoOpen) {
				new ActivityProductsWapper().update(productId, MapUtil.hashMap("isolation", true));
			}

			// check GetProductListByProductIdList
			checkByProductList(prodList, 300, 0, 0, false, 0);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_012() {
		Logger.start(true, "简表接口输出增加最低 原价、新客价、VIP价、活动价");
		try {
			// 发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			Logger.comment("修改商品规格信息,设置新客价格最便宜");
			// 场景描述1规格新客价格最便宜
			addpro.getProduct().getCatalogList().remove(1);
			CatalogSaveModel c = addpro.getProduct().getCatalogList().get(0);
			c.setNewPrice(1d);
			c.setVipPrice(2d);
			c.setPrice(3d);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject()
					.get("ProductId").getAsString();
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			
			Integer activityId = ActivityCallService.createIsolationActivityInProcess();
			List<String> prodList = Arrays.asList(productId);

			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			verifyDB(productId, activityId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_013() {
		Logger.start(true, "直播快速发布商品，获取失败（与Tc_GetNewProductListBySellerIdList_003问题一致）");
		try {
			AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			LiveRoom createlive = LiveRoomCallService
					.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(sellerId));
			LiveRoomCallService.UpdateLiveTimeToStart(createlive.getId());
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), createlive.getUserId());
			addProdReq.getProduct().setLiveRoomId(createlive.getId());
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
			List<String> prodList = Arrays.asList(productId);

			// GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");

			Logger.verifyEquals(true, getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.get("ProductList").isJsonNull(), "验证查询出来的数据为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_014() {
		Logger.start(true, "简表接口输出增加是否包税");
		try {
			// 发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			Logger.comment("修改商品规格信息,设置新客价格最便宜");
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject()
					.get("ProductId").getAsString();
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Integer activityId = ActivityCallService.createIsolationActivityInProcess();
			List<String> prodList = Arrays.asList(productId);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			String TariffType = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject().get("TariffType").toString();
			Logger.verifyEquals("0", TariffType, "测试是否包税");
			verifyDB(productId, activityId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_015() {
		Logger.start(true, "品牌id，销售佣金判断");
		try {
			sellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));

			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2
					.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data")
					.getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId, productId, 2);
			UpdateCatalogCommisionsBean updatecatalogcommisionsBean = new UpdateCatalogCommisionsBean();
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());
			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			List<YmtCatalogsI> catalogslist = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			saleCommissionDto.setCatalogId(catalogslist.get(0).getsCatalogId());
			saleCommissionDto.setSaleCommission(new BigDecimal("0.07"));

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			UpdateCatalogCommisionsCall updatecatalogcommisionsCall = new UpdateCatalogCommisionsCall();
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("200", updatecatalogcommisionsCall.getString("Code"), "验证Code");
			YmtCatalogsI catalogsI = new YmtCatalogsIWapper()
					.selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			Logger.verifyEquals("0.0700", catalogsI.getSaleCommissionPercent(), "验证SaleCommissions");

			List<String> prodList = Arrays.asList(productId);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");

			// verifyDB(productId, activityId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_016() {
		Logger.start(true, "简表接口输出增加规格库存");
		try {
			// 发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject()
					.get("ProductId").getAsString();
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());

			Integer activityId = ActivityCallService.createIsolationActivityInProcess();
			List<String> prodList = Arrays.asList(productId);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject Product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();
			Logger.verifyEquals("2000000", Product.get("CatalogStock") + "", "验证规格库存");
			// verifyDB(productId, activityId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductListByProductIdList_017() {
		Logger.start(true, "简表接口验证是直播间快速发布商品（与Tc_GetNewProductListBySellerIdList_003问题一致）");
		try {
			AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			LiveRoom createlive = LiveRoomCallService
					.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(sellerId));
			LiveRoomCallService.UpdateLiveTimeToStart(createlive.getId());
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), createlive.getUserId());
			addProdReq.getProduct().setLiveRoomId(createlive.getId());
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
			List<String> prodList = Arrays.asList(productId);

			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			Logger.verifyEquals(
					"4", getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
							.get("ProductList").getAsJsonArray().get(0).getAsJsonObject().get("ProductType") + "",
					"验证商品的是否直播快速发布商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

	// 渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_018() {
		Logger.start(true, "查询限时抢八折后价格");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, false);
			double price = 123.6;
			addAgentProductBean.getCatalogList().forEach(a -> {
				a.getAgentPriceList().forEach(b -> {
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 创建限时抢购活动
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});
			List<String> catalogs = new ArrayList<String>();

			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId,
					productId, catalogList);
			initProductaddactivity.getProductList().forEach(a -> {
				a.getCatalogList().forEach(b -> {
					catalogs.add(b.getCatalogId());
					b.setDiscount(new BigDecimal("8"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(4000);
			
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(Arrays.asList(productId));
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			
			
			JsonObject callAndGetReturnData = getProductListByProductIdListCall.getJsonObject();
			JsonObject asJsonObject1 = callAndGetReturnData.getAsJsonObject("Data").getAsJsonArray("ProductList").get(0).getAsJsonObject();
			Logger.verifyEquals(price, asJsonObject1.get("MinQuotePrice").getAsDouble(), "验证是否为八折价格");
			Logger.verifyEquals(price * 0.8, asJsonObject1.get("MinPrice").getAsDouble(), "验证是否为八折价格");
			Logger.verifyEquals(price * 0.8, asJsonObject1.get("MaxPrice").getAsDouble(), "验证是否为八折价格");
			Logger.verifyEquals(price * 0.8, asJsonObject1.get("MinActivityPrice").getAsDouble(), "验证是否为八折价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	private static int globalSellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_019() {
		Logger.start(true, "查询优选团价格，多佣金比例");
		try {
			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2
					.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data")
					.getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId, productId, 2);
			// 设置佣金比例、获取规格id、根据规格id，商品id，修改商品佣金
			BigDecimal saleCommission = new BigDecimal("0.111");
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(x -> x.getsCatalogId()).collect(Collectors.toList());
			ProductManagerCallServiceV2.UpdateCatalogCommisions(addSellerProductRequest.getSellerId(), productId,
					catalogIds.get(0), addSellerProductRequest.getSellerName(), saleCommission);
			ProductManagerCallServiceV2.UpdateCatalogCommisions(addSellerProductRequest.getSellerId(), productId,
					catalogIds.get(1), addSellerProductRequest.getSellerName(), saleCommission);
			
			Thread.sleep(4000);
			
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(Arrays.asList(productId));
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			JsonArray asJsonArray = getProductListByProductIdListCall.getJsonObject().getAsJsonObject("Data").getAsJsonArray("ProductList");
			//判断各个佣金价格
			asJsonArray.forEach(j->{
				JsonObject cataLog = j.getAsJsonObject();
				float price = cataLog.get("MinPrice").getAsFloat();
				JsonArray CommissionList = cataLog.getAsJsonArray("CommissionList");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.6*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(0).getAsDouble()), "验证V1佣金");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.7*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(1).getAsDouble()), "验证V2佣金");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.83*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(2).getAsDouble()), "验证V3佣金");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.96*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(3).getAsDouble()), "验证V4佣金");
			});
			
			
			
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_020() {
		Logger.start(true, "查询礼包商品，多佣金比例");
		try{
			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId,productId,1);
			List<BigDecimal> saleCommissions = Arrays.asList(new BigDecimal("0.0700"),new BigDecimal("0.0800"),new BigDecimal("0.0900"),new BigDecimal("0.1000"));
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(x->x.getsCatalogId()).collect(Collectors.toList());
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(globalSellerId,productId,catalogIds.get(0),addSellerProductRequest.getSellerName(), saleCommissions);
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(globalSellerId,productId,catalogIds.get(1),addSellerProductRequest.getSellerName(), saleCommissions);

			Thread.sleep(4000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(Arrays.asList(productId));
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			JsonArray asJsonArray = getProductListByProductIdListCall.getJsonObject().getAsJsonObject("Data").getAsJsonArray("ProductList");
			//判断各个佣金价格
			asJsonArray.forEach(j->{
				JsonObject cataLog = j.getAsJsonObject();
				float price = cataLog.get("MinPrice").getAsFloat();
				JsonArray CommissionList = cataLog.getAsJsonArray("CommissionList");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(0).floatValue()),String.format("%.2f",CommissionList.get(0).getAsDouble()), "验证V1佣金");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(1).floatValue()),String.format("%.2f",CommissionList.get(1).getAsDouble()), "验证V2佣金");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(2).floatValue()),String.format("%.2f",CommissionList.get(2).getAsDouble()), "验证V3佣金");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(3).floatValue()),String.format("%.2f",CommissionList.get(3).getAsDouble()), "验证V4佣金");
			});
			
			
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_021() {
		Logger.start(true, "查询商品简表，判断推荐语");
		try{
			// 发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().setRecomReason("推荐语");
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject()
					.get("ProductId").getAsString();
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());

			Integer activityId = ActivityCallService.createIsolationActivityInProcess();
			List<String> prodList = Arrays.asList(productId);
			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject Product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();
			Logger.verifyEquals("推荐语", Product.get("RecomReason").getAsString() + "", "验证规格库存");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_022() {
		Logger.start(true, "查询商品简表，价格服务增加币种");
		try{
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());

			Integer activityId = ActivityCallService.createIsolationActivityInProcess();
			List<String> prodList = Arrays.asList(productId);
			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject Product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();

			//注释 返回MarketAmount字段没有  wuwen
			//Logger.verifyEquals(123.1, Product.get("MarketAmount").getAsDouble(),"验证市场价");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_023() {
		Logger.start(true, "查询商品简表，价格服务增加市场价");
		try{
			rootUserId = AgentUsers.vipRootUserId;
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			addAgentProductBean.getCatalogList().get(0).setMarketAmount(123.1);
			addAgentProductBean.getCatalogList().get(0).setMarketPrice(333);
			addAgentProductBean.setMarketCurrency("CNY");
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Integer activityId = ActivityCallService.createIsolationActivityInProcess();
			List<String> prodList = Arrays.asList(productId);
			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(prodList);
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("BCode"), "返回BCode");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject Product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();
			
//			Logger.verifyEquals(123.1, Product.get("MarketAmount").getAsDouble(),"验证市场价");
			Logger.verifyEquals(123.1, Product.get("MinMarketAmount").getAsDouble(),"验证神器市场价");
			JsonObject CurrencyExchangeRate = Product.getAsJsonObject("MarketCurrencyExchangeRate");
			Logger.verifyEquals("人民币", CurrencyExchangeRate.get("CurrencyName").getAsString(),"验证神器币种");
			Logger.verifyEquals(1.0, CurrencyExchangeRate.get("ExchangeRate").getAsDouble(),"验证汇率");
			Logger.verifyEquals(1.002, CurrencyExchangeRate.get("OnshoreExchangeRate").getAsDouble(),"验证在岸汇率");
			Logger.verifyEquals(333.0, Product.get("MinMarketPrice").getAsDouble(),"验证神器专柜价");
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId, productId);
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_024() {
		Logger.start(true, "查询商品简表，增加publishType");
		try{
			// 发布商品
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(288484);
			addProdReq.getProduct().setPublishType(1);
			String ProductId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(Arrays.asList(ProductId));
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject Product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();
			Logger.verifyEquals(1, Product.get("PublishType").getAsInt(),"验证publishType");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_025() {
		Logger.start(true, "查询商品简表，增加Tag");
		try{
			// 发布商品
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(288484);
			addProdReq.getProduct().setProductTags(Arrays.asList("标签1","标签2"));
			String ProductId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(Arrays.asList(ProductId));
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject Product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();
			Logger.verifyEquals("标签1", Product.getAsJsonArray("Tag").get(0).getAsString(),"验证publishType");
			Logger.verifyEquals("标签2", Product.getAsJsonArray("Tag").get(1).getAsString(),"验证publishType");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductListByProductIdList_026() {
		Logger.start(true, "查询商品简表，增加奢品");
		try{
			// 发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(3383);
			addpro.getProduct().getCatalogList().get(0).setPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setNewPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setVipPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setMarketPrice(18000);
			String ProductId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			GetProductListByProductIdListBean.setNextActivityExpire(1);
			GetProductListByProductIdListBean.setProductIdList(Arrays.asList(ProductId));
			getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
			getProductListByProductIdListCall.callService();
			Logger.verifyEquals("200", getProductListByProductIdListCall.getString("Code"), "返回Code");
			Logger.verifyNotNull(getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList"), "验证商品是否存在");
			JsonObject product = getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
					.getAsJsonArray("ProductList").get(0).getAsJsonObject();
			
			Logger.verifyEquals(true,product.get("IsLuxury").getAsBoolean(),"验证商品是否奢侈品");
			//注释 20210113 wuwen 返回字段没有CatalogList字段
//			Logger.verifyEquals(true,product.getAsJsonArray("CatalogList").get(0).getAsJsonObject().get("IsLuxury").getAsBoolean(),"验证规格1奢侈品");
//			Logger.verifyEquals(true,product.getAsJsonArray("CatalogList").get(1).getAsJsonObject().get("IsLuxury").getAsBoolean(),"验证规格2奢侈品");
		
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	

	public static void checkByProductList(List<String> prodList, int NextActivityExpire, int prodInActivityId,
			int liveId, boolean isTradeIsolation, int nextActivityId) throws Exception {
		YMTDateUtil.waitTime(2);
		List<ProductInListBean> tgtProductInListBeanList = new ArrayList<>();
		prodList.forEach(ele -> {
			try {
				ProductInListBean productInListBean = ProductQueryCallService.getProductInListBean(ele,
						prodInActivityId, liveId);
				productInListBean.setNextActivityId(nextActivityId);
				tgtProductInListBeanList.add(productInListBean);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});

		JSONObject ret;
		String chkdesc;
		if (isTradeIsolation) {
			// 交易隔离接口
			ret = getProductListByTradeIsolationCall.search(prodList, NextActivityExpire);
			chkdesc = "检查 GetProductListByTradeIsolation";
		} else {

			// 普通交易不隔离接口
			ret = getProductListByProductIdListCall.search(prodList, NextActivityExpire);
			chkdesc = "检查 GetProductListByProductIdList";
		}

		// 返回码检查
		Logger.verifyEquals(200, ret.getInt("Code"), "返回码检查");

		// 返回值取数据
		List<ProductInListBean> actProductInListBeanList = new ArrayList<>();
		JSONArray prodListAry = ret.getJSONObject("Data").getJSONArray("ProductList");
		for (int i = 0; i < prodListAry.length(); i++) {
			actProductInListBeanList.add(
					ProductQueryCallService.getBeanFromJson(prodListAry.getJSONObject(i), ProductInListBean.class));
		}

		// 比对
		ProductQueryCallService.compareProductInListBean(prodList, tgtProductInListBeanList, actProductInListBeanList,
				chkdesc);

	}

	public static void checkByProductList(List<String> prodList, int prodInActivityId, int liveId,
			boolean isTradeIsolation) throws Exception {

		checkByProductList(prodList, 1, prodInActivityId, liveId, isTradeIsolation, 0);
	}

	private void verifyDB(String pid, Integer inaid) throws Exception {
		ArrayList<ProductInListDto> productList = getProductListByProductIdListCall.getProductList();
		// 查询当前时间在 start到end+7 的新商品 按新品时间倒序
		ProductsWapperV2 ProductsWapper = new ProductsWapperV2();
		if (productList != null && productList.size() != 0) {
			BasicDBObject search = new BasicDBObject();
			search.append("sid", sellerId);
			search.append("spid", pid);
			BasicDBObject orderBy = new BasicDBObject("newstart", -1);
			List<Map> dlist = ProductsWapper.selectProduct(search, orderBy);

			System.out.println(dlist);
			System.out.println(FormatUtil.beanToGSONString(productList));
			for (int i = 0; i < productList.size(); i++) {
				ProductInListDto preutrn = productList.get(i);
				Map pdb = dlist.get(i);
				Logger.comment("验证商品:" + preutrn.getProductId());
				Logger.verifyEquals(preutrn.getProdId(), pdb.get("ipid").toString(), "验证ipid");
				Logger.verifyEquals(preutrn.getProductId(), pdb.get("spid").toString(), "验证spid");
				Logger.verifyEquals(preutrn.getTitle(), pdb.get("title"), "验证title");
				Logger.verifyEquals(preutrn.getMainPic(), ((List) pdb.get("pics")).get(0), "验证MainPic");
				Logger.verifyEquals(preutrn.getValidStart(),
						YMTDateUtil.getDate(pdb.get("start").toString(), YMTDateUtil.YMDGMT, Locale.US), "验证start");
				Logger.verifyEquals(preutrn.getValidEnd(),
						YMTDateUtil.getDate(pdb.get("end").toString(), YMTDateUtil.YMDGMT, Locale.US), "验证end");
				// Logger.verifyEquals(preutrn.getMinPrice().toString(),
				// pdb.get("minp").toString().split(",")[0].toString(),
				// "验证minp");
				Logger.verifyEquals(preutrn.getMaxPrice().toString(),
						pdb.get("maxp").toString().split(",")[0].toString(), "验证maxp");
				Logger.verifyEquals(preutrn.getSellerId(), pdb.get("sid"), "验证sid");
				Logger.verifyEquals(preutrn.getSellerName(), pdb.get("sname"), "验证sname");
				Logger.verifyEquals(preutrn.getCountryId(), pdb.get("country"), "验证country");
				Logger.verifyEquals(preutrn.getIsPspProduct(), pdb.get("ispsp"), "验证ispsp");
				// 最低价这里验证
				String[] mlst = pdb.get("minp").toString().split(",");
				if (inaid == 0) {
					// 没有活动时候这个是原价最低
					Logger.verifyEquals(Double.valueOf(mlst[0]), preutrn.getMinPrice(), "验证MinPrice");
				}
				Logger.verifyEquals(Double.valueOf(mlst[0]), preutrn.getMinQuotePrice(), "验证MinQuotePrice");
				Logger.verifyEquals(Double.valueOf(mlst[1]), preutrn.getMinNewGuestPrice(), "验证MinNewGuestPrice");
				Logger.verifyEquals(Double.valueOf(mlst[2]), preutrn.getMinVipPrice(), "验证MinVipPrice");

				// 待确认这个逻辑 由于目前改成newend+7天 可能出现不在start到end之间的数据此时返回false
				// 这里按照原来的逻辑计算
				search = new BasicDBObject();
				search.append("sid", sellerId);
				search.append("isnew", true);
				search.append("newstart", new BasicDBObject("$lte", new Date()));
				search.append("newend", new BasicDBObject("$gte", new Date()));
				search.append("spid", preutrn.getProductId());
				orderBy = new BasicDBObject("newstart", -1);
				List<Map> isnewm = ProductsWapper.selectProduct(search, orderBy);
				// Logger.debug("真正的新品:"+isnewm);
				Logger.verifyEquals(preutrn.getIsNewProduct(), (boolean) pdb.get("isnew") == true && isnewm.size() == 1,
						"验证isnew");
				//
				Logger.verifyEquals(preutrn.getTariffType(), Double.valueOf(pdb.get("tariffy").toString()).intValue(),
						"验证是否包税");
				Logger.verifyEquals(preutrn.getDeliveryMethod(), pdb.get("deliv"), "验证发货方式");
				Logger.verifyEquals(preutrn.getIsHotRecmd(), pdb.get("istop"), "验证热推");
				Logger.verifyEquals(preutrn.getOwnProduct() == true ? 1 : 0, pdb.get("own"), "验证直营商品");
				// 免税/包邮
				// 包邮默认true
				// 有templates运费模板并且tlid 模板id大于0 不包邮
				if (pdb.get("templates") != null && ((List<Map>) pdb.get("templates")).size() > 0) {
					if (((List<Map>) pdb.get("templates")).stream().filter(map -> {
						return (int) map.get("tlid") > 0;
					}).count() > 0) {
						Logger.verifyEquals(preutrn.getIsFreeShipping(), false, "验证是否包邮");
					} else {
						Logger.verifyEquals(preutrn.getIsFreeShipping(), true, "验证是否包邮");
					}

				} else {
					Logger.verifyEquals(preutrn.getIsFreeShipping(), true, "验证是否包邮");
				}
				Logger.verifyEquals(preutrn.getNewStartTime(),
						YMTDateUtil.getDate(pdb.get("newstart").toString(), YMTDateUtil.YMDGMT, Locale.US),
						"验证newstart");
				Logger.verifyEquals(preutrn.getNewEndTime(),
						YMTDateUtil.getDate(pdb.get("newend").toString(), YMTDateUtil.YMDGMT, Locale.US), "验证newend");
				search = new BasicDBObject();
				search.append("spid", sellerId);
				// 验证规格相关
				List<Map> clist = ProductsWapper.selectCatalogs(search, null);
				// 库存有2种算法
				Integer stock = 0;
				if (clist != null && clist.size() > 0) {
					Boolean haspresale = false;
					Boolean allpresale = true;
					for (int ci = 0; ci < clist.size(); ci++) {
						Map mcatalog = clist.get(ci);
						boolean presale = (boolean) mcatalog.get("presale");
						stock += Integer.valueOf(mcatalog.get("stock").toString());
						if (presale) {
							haspresale = true;
							allpresale = allpresale & presale;
						}
					}
					Logger.verifyEquals(preutrn.getIsAnyPreSale(), haspresale, "验证有预售");
					Logger.verifyEquals(preutrn.getIsAllPreSale(), allpresale, "验证全部预售");
				}
				// 规格end
				// 查询活动数据
				search = new BasicDBObject();
				search.append("spid", sellerId);
				search.append("start", new BasicDBObject("$lte", new Date()));
				search.append("end", new BasicDBObject("$gte", new Date()));
				List<Map> alist = ProductsWapper.selectActivityProducts(search, null);
				if (alist != null && alist.size() > 0) {
					Logger.debug("alist:" + alist);
					List<ActivityProducts> ActivityCatalogInfoList = (List<ActivityProducts>) FormatUtil
							.GSONToObject(alist.toString(), new TypeToken<List<ActivityProducts>>() {
							}.getType());
					// 查出来的活动数据中是否有有效的,有效则库存为活动库存 无效则是所有规格库存
					Integer aaid = ActivityCatalogInfoList.stream()
							.collect(Collectors.summingInt(ActivityProducts::getActivityId));
					if (aaid > 0) {
						int activityStock = ActivityCatalogInfoList.get(0).getCatalogs().stream()
								.collect(Collectors.summingInt(ActivityCatalogInfo::getActivityStock));
						Logger.verifyEquals(new BigDecimal(preutrn.getActivityMarketPrice()).setScale(2),
								new BigDecimal(ActivityCatalogInfoList.get(0).getMarketPrice()).setScale(2),
								"验证MarketPrice");
						Logger.verifyEquals(preutrn.getStock(), activityStock, "验证全部预售");
					} else {
						Logger.verifyEquals(preutrn.getStock(), stock, "验证stock");
					}

				}

				// 验证活动
				if (inaid != 0) {
					ArrayList<Map> mapss = activityProductsWapper.getByProdInActivityIds(inaid);
					for (Map maps : mapss) {
						// 开始结束时间
						Date starttime = (Date) maps.get("start");
						Date endtime = (Date) maps.get("end");
						// 获取活动规格
						List<Map> catalogsAry = (List<Map>) FormatUtil.GSONToObject(maps.get("catalogs").toString(),
								new TypeToken<List<Map>>() {
								}.getType());
						Stream<Map> hasStock = catalogsAry.stream()
								.filter(mapper -> (Double.valueOf(mapper.get("stock").toString()) > 0));
						Double max = catalogsAry.stream().map(mapper -> Double.valueOf(mapper.get("price").toString()))
								.max(Comparator.comparing(u -> u)).get();
						Double min = catalogsAry.stream().map(mapper -> Double.valueOf(mapper.get("price").toString()))
								.min(Comparator.comparing(u -> u)).get();
						List cids = hasStock.map(mapper -> mapper.get("cid")).collect(Collectors.toList());
						// 如果售罄 不会出现在本场和下一次
						if (cids == null || cids.size() == 0) {
							Logger.verifyEquals(0d, preutrn.getMinActivityPrice(), "验证MinActivityPrice");
						} else {
							if (starttime.getTime() > YMTDateUtil.getDate().getTime()) {
								// 未来-next
								Logger.verifyEquals(0d, preutrn.getMinActivityPrice(), "验证MinActivityPrice");
							} else {
								// 当前活动
								Logger.verifyEquals(min, preutrn.getMinActivityPrice(), "验证MinActivityPrice");
							}
						}
					}
				}
			}
		}

	}

}
